<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: PERModel Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00172.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a>  </div>
  <div class="headertitle">
<div class="title">PERModel Class Reference<div class="ingroups"><a class="el" href="a00511.html">analogueModels - AnalogueModel implementations</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="PERModel" --><!-- doxytag: inherits="AnalogueModel" -->
<p>This class applies a parameterized packet error rate to incoming packets. This allows the user to easily study the robustness of its system to packet loss.  
 <a href="a00172.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00402_source.html">PERModel.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for PERModel:</div>
<div class="dyncontent">
<div class="center"><img src="a00927.png" border="0" usemap="#PERModel_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for PERModel:</div>
<div class="dyncontent">
<div class="center"><img src="a00928.png" border="0" usemap="#PERModel_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00929.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af88deff4c0b8f609b6cc5a2c15896592"></a><!-- doxytag: member="PERModel::PERModel" ref="af88deff4c0b8f609b6cc5a2c15896592" args="()" -->
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00172.html#af88deff4c0b8f609b6cc5a2c15896592">PERModel</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The <a class="el" href="a00172.html" title="This class applies a parameterized packet error rate to incoming packets. This allows the user to eas...">PERModel</a> constructor takes as argument the packet error rate to apply (must be between 0 and 1). <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00172.html#a2a72696b1edd833f3b972cccaaaca838">initFromMap</a> (const <a class="el" href="a00009.html#ab1820eb5285a02a2464be54ec651feab">ParameterMap</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the analog model from XML map data.  <a href="#a2a72696b1edd833f3b972cccaaaca838"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00172.html#a90557ea84420483d5e2cc39cc2cce017">filterSignal</a> (airframe_ptr_t, const <a class="el" href="a00065.html">Coord</a> &amp;, const <a class="el" href="a00065.html">Coord</a> &amp;)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Has to be overriden by every implementation.  <a href="#a90557ea84420483d5e2cc39cc2cce017"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a32ced82d925f432ef880595a3d202be8"></a><!-- doxytag: member="PERModel::packetErrorRate" ref="a32ced82d925f432ef880595a3d202be8" args="" -->
double&#160;</td><td class="memItemRight" valign="bottom"><b>packetErrorRate</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>This class applies a parameterized packet error rate to incoming packets. This allows the user to easily study the robustness of its system to packet loss. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Jérôme Rousselot &lt;<a href="mailto:jerome.rousselot@csem.ch">jerome.rousselot@csem.ch</a>&gt; </dd></dl>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a90557ea84420483d5e2cc39cc2cce017"></a><!-- doxytag: member="PERModel::filterSignal" ref="a90557ea84420483d5e2cc39cc2cce017" args="(airframe_ptr_t, const Coord &amp;, const Coord &amp;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PERModel::filterSignal </td>
          <td>(</td>
          <td class="paramtype">airframe_ptr_t&#160;</td>
          <td class="paramname"><em>frame</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname"><em>sendersPos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="a00065.html">Coord</a> &amp;&#160;</td>
          <td class="paramname"><em>receiverPos</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Has to be overriden by every implementation. </p>
<p>Filters a specified AirFrame's <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a> by adding an attenuation over time to the <a class="el" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">frame</td><td>The incomming frame. </td></tr>
    <tr><td class="paramname">sendersPos</td><td>The position of the frame sender. </td></tr>
    <tr><td class="paramname">receiverPos</td><td>The position of frame receiver. </td></tr>
  </table>
  </dd>
</dl>

<p>Implements <a class="el" href="a00009.html#a3242bc36a68dab53551d4ab1f1dab010">AnalogueModel</a>.</p>

<p>References <a class="el" href="a00192.html#a0beeef0f27c33145a0fca521df1c5f5c">Signal::addAttenuation()</a>, and <a class="el" href="a00212.html#a453ce64062fa7afd7398735a9cf499a6">TimeMapping&lt; Interpolator &gt;::setValue()</a>.</p>
<div class="fragment"><pre class="fragment">                                                                                {
  <a class="code" href="a00192.html" title="The signal class stores the physical representation of the signal of an AirFrame.">Signal</a>&amp;   signal = frame-&gt;getSignal();
  <span class="comment">//simtime_t start  = signal.getReceptionStart();</span>
  <span class="comment">//simtime_t end    = signal.getReceptionEnd();</span>

  <span class="keywordtype">double</span> attenuationFactor = 1;  <span class="comment">// no attenuation</span>
  <span class="keywordflow">if</span>(packetErrorRate &gt; 0 &amp;&amp; uniform(0, 1) &lt; packetErrorRate) {
    attenuationFactor = 0;  <span class="comment">// absorb all energy so that the receveir cannot receive anything</span>
  }

  <a class="code" href="a00212.html">TimeMapping&lt;Linear&gt;</a>* attMapping = <span class="keyword">new</span> <a class="code" href="a00212.html">TimeMapping&lt;Linear&gt;</a> ();
  <a class="code" href="a00013.html" title="Defines an argument for a mapping.">Argument</a> arg;
  attMapping-&gt;<a class="code" href="a00212.html#a453ce64062fa7afd7398735a9cf499a6" title="Changes the value of the function at the specified position.">setValue</a>(arg, attenuationFactor);
  signal.<a class="code" href="a00192.html#a0beeef0f27c33145a0fca521df1c5f5c" title="Adds a function representing an attenuation of the signal.">addAttenuation</a>(attMapping);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a2a72696b1edd833f3b972cccaaaca838"></a><!-- doxytag: member="PERModel::initFromMap" ref="a2a72696b1edd833f3b972cccaaaca838" args="(const ParameterMap &amp;)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool PERModel::initFromMap </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a00009.html#ab1820eb5285a02a2464be54ec651feab">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialize the analog model from XML map data. </p>
<p>This method should be defined for generic analog model initialization.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">params</td><td>The parameter map which was filled by XML reader.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>true if the initialization was successfully. </dd></dl>

<p>Reimplemented from <a class="el" href="a00009.html#a9c52493cdf1baa4110a83869e8bc13c5">AnalogueModel</a>.</p>
<div class="fragment"><pre class="fragment">                                                     {
    ParameterMap::const_iterator it;
    <span class="keywordtype">bool</span>                         bInitSuccess = <span class="keyword">true</span>;

    <span class="keywordflow">if</span> ((it = params.find(<span class="stringliteral">&quot;seed&quot;</span>)) != params.end()) {
        srand( ParameterMap::mapped_type(it-&gt;second).longValue() );
    }
    <span class="keywordflow">if</span> ((it = params.find(<span class="stringliteral">&quot;packetErrorRate&quot;</span>)) != params.end()) {
        packetErrorRate = ParameterMap::mapped_type(it-&gt;second).doubleValue();
    }
    <span class="keywordflow">else</span> {
        bInitSuccess = <span class="keyword">false</span>;
        opp_warning(<span class="stringliteral">&quot;No packetErrorRate defined in config.xml for PERModel!&quot;</span>);
    }

    <span class="keywordflow">return</span> <a class="code" href="a00172.html#a2a72696b1edd833f3b972cccaaaca838" title="Initialize the analog model from XML map data.">AnalogueModel::initFromMap</a>(params) &amp;&amp; bInitSuccess;
}
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/analogueModel/<a class="el" href="a00402_source.html">PERModel.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/src/modules/analogueModel/PERModel.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00172.html">PERModel</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
